package com.ash.scheduling;


import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.ash.service.AccountCostInfoService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
@RequiredArgsConstructor
@Slf4j
public class CostSetupDataTask {
    private final AccountCostInfoService accountCostInfoService;

    @Scheduled(cron = "00 00/5 * * * *")
    public void dataMove() {
        log.info("开始执行定时任务测试dataMove,当前时间{}", DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN));
        System.out.println(" ");
        DateTime dateTime = DateUtil.offsetDay(new Date(), -7);
        String endDateStr = DateUtil.format(dateTime, DatePattern.NORM_DATE_PATTERN);
        accountCostInfoService.moveData(endDateStr);
        log.info("结束执行定时任务测试dataMove,当前时间{}", DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN));

    }

    public static void main(String[] args) {
        System.out.println("测试02");
        System.out.println("这是一个平凡的世界");
        System.out.println("测试02");
        System.out.println("测试02");
        System.out.println("大师傅大师傅");
        System.out.println("测试02");
    }
}
